package com.example.demo.controller;

import com.example.demo.mapper.GoodsMapper;
import com.example.demo.pojo.Dto.GoodsDto;
import com.example.demo.service.CategoryService;
import com.example.demo.service.GoodsService;
import com.example.demo.utill.ResponseResult;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

@Controller
@RequestMapping("/category")
public class CategoryController {
    @Resource
    private CategoryService categoryService;
    @Resource
    private GoodsService goodsService;
    @RequestMapping("/selectCategory")
    @ResponseBody
    public ResponseResult selectCategory(){
        ResponseResult res=new ResponseResult();
        res.setCode(200);
        res.setData(categoryService.selectCategory());
        return res;
    }
    @RequestMapping("/selectClassify")
    @ResponseBody
    public PageInfo<GoodsDto> selectClassify(@RequestParam(value = "id",required = false,defaultValue = "")int id,
                                             @RequestParam(value = "pageNum",required = false,defaultValue = "1")int pageNum,
                                             @RequestParam(value = "pageSize",required = false,defaultValue = "15")int pageSize){
        return goodsService.selectClassify(id, pageNum, pageSize);
    }
}
